package com.shujia.scala

import scala.actors.Actor

object Demo22Actor {
  def main(args: Array[String]): Unit = {

    /**
      * scala  自带的多线程 actor
      *
      */

    //启动actor

    new Master1().start()



    val list = List(1, 2, 3, 4, 5, 6, 7, 8, 9)
    for (elem <- list) {

      println("main:" + elem)

      Thread.sleep(1000)

    }


  }
}

class Master1 extends Actor {

  //相当于run 方法
  override def act(): Unit = {


    val list = List(1, 2, 3, 4, 5, 6, 7, 8, 9)


    for (elem <- list) {

      println("Master:" + elem)

      Thread.sleep(1000)

    }

  }
}

